package com.wujie.section091;

import java.util.Iterator;

/**
 * Created by wujieliu on 2017/10/25.
 */
public class DinerMenu implements Menu {
    static final int MAX_ITEMS = 6;
    int numberOfItems = 0;
    MenuItem[] menuItems;

    public DinerMenu() {
        menuItems = new MenuItem[MAX_ITEMS];
        addItem("Vege", "dededd", true, 2.99);
        addItem("Vege1", "dededd1", false, 4.99);
        addItem("Vege2", "dededd2", false, 3.99);
        addItem("Vege3", "dededd3", true, 5.99);
    }

    public void addItem(String name, String description, boolean vegetarian, double price) {
        MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
        if (numberOfItems >= MAX_ITEMS) {
            System.err.println("Sorry ,menu is full");
        } else {
            menuItems[numberOfItems] = menuItem;
            numberOfItems = numberOfItems + 1;
        }
    }

    //    public MenuItem[] getMenuItems() {
//        return menuItems;
//    }
    public Iterator createIterator() {
        return new DinerMenuIterator(menuItems);
    }
}
